//
//  LoginUserJobView.m
//  BGM
//
//  Created by 我要变好看 on 2019/1/22.
//  Copyright © 2019 com.alirtc.demo. All rights reserved.
//

#import "LoginUserJobView.h"
#import "Common.h"
#import "MeChangeTableViewCell.h"

@implementation LoginUserJobView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self != nil) {
        
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, SCREENH)];
        bgView.backgroundColor = [UIColor grayColor];
        bgView.alpha = 0.4;
        [self addSubview:bgView];
        
       
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
        [bgView addGestureRecognizer:tap];
        
        
        
        
        UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, SCREENW-60, SCREENH-120)];
        titleView.backgroundColor = [UIColor whiteColor];
        titleView.center = CGPointMake(SCREENW/2, SCREENH/2);
        titleView.layer.cornerRadius = 8;
        titleView.layer.masksToBounds = YES;
        [self addSubview:titleView];
        
        UILabel *userTitle = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 200, 50)];
        userTitle.font = [UIFont boldSystemFontOfSize:16];
        userTitle.text = @"行业";
        [titleView addSubview:userTitle];
        
        self.userTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 50, titleView.frame.size.width, titleView.frame.size.height-100)];
        self.userTable.delegate = self;
        self.userTable.dataSource = self;
        self.userTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        [titleView addSubview:self.userTable];
        
        
        
        UIButton *btn5 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width-150, titleView.frame.size.height-40, 60, 30)];
        [btn5 setTitle:@"确定" forState:UIControlStateNormal];
        [btn5 setTitleColor:bgmmainColor forState:UIControlStateNormal];
        btn5.backgroundColor = bgmyelloeColor;
        btn5.layer.cornerRadius = 5;
        btn5.layer.masksToBounds = YES;
        btn5.tag = 65;
        [btn5 addTarget:self action:@selector(clickTitleSele:) forControlEvents:UIControlEventTouchUpInside];
        btn5.titleLabel.font = [UIFont systemFontOfSize:13];
        [titleView addSubview:btn5];
        
        UIButton *btn6 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width-70, titleView.frame.size.height-40,60, 30)];
        [btn6 setTitle:@"取消" forState:UIControlStateNormal];
        [btn6 setTitleColor:bgmmainColor forState:UIControlStateNormal];
        btn6.backgroundColor = [UIColor whiteColor];
        btn6.layer.cornerRadius = 5;
        btn6.layer.masksToBounds = YES;
        btn6.titleLabel.font = [UIFont systemFontOfSize:13];
        btn6.tag = 66;
        [btn6 addTarget:self action:@selector(clickTitleSele:) forControlEvents:UIControlEventTouchUpInside];
        
        [titleView addSubview:btn6];

    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titleContents.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"MeChangeTableViewCell";
    MeChangeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[MeChangeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    NSDictionary *dic = [self.titleContents objectAtIndex:indexPath.row];
    cell.usertltleLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
    cell.seleBtn.hidden = YES;
    cell.usertltleLabel.frame = CGRectMake(20, 15, 300, 30);
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *dic = [self.titleContents objectAtIndex:indexPath.row];
    NSString *str = [NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
    [self.jobDelegate changeJob:str];
   
}

- (void)clickTitleSele:(UIButton *)btn{
    [self.jobDelegate hiddenJobview];
}
- (void)tap{
    [self.jobDelegate hiddenJobview];
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
